package com.itheima.d0_homework.timu3;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student(1,"张无忌","河北");
        Student s2 = new Student(2,"张三丰","河南");
        Student s3 = new Student(3,"赵敏","蒙古");
        Student s4 = new Student(4,"周芷若","四川");

        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);

        int index = 0;

        for (int i = 0; i < list.size(); i++) {
            Student student = list.get(i);

            String name = student.getName();
                index= i;

            if ("张三丰".equals(name)){

                Student student1 = new Student(student.getId(), student.getName(), "山东");
                    list.set(index,student1);
            }
        }
        for (Student message : list) {
            System.out.println(message);
        }

    }
}
